<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$imgUrl = Url::to("@web/img/wx/");
$jsUrl = Url::to("@web/js/wx/");
$basejsUrl = Url::to("@web/js/");
$cssUrl = Url::to("@web/css/wx/");
//var_dump($rCards);
//die;
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>领取礼物</title>
    <link rel="stylesheet" href="<?= $cssUrl ?>receive_gift.css"/>
    <link rel="stylesheet" href="<?= $cssUrl ?>weui.css"/>
    <script src="<?= $basejsUrl ?>jquery.js"></script>
    <script src="<?=$basejsUrl?>/tools.js"></script>
    <script src="<?= $jsUrl ?>/zepto.min.js"></script>
    <!--    <script type="text/javascript" src="--><? //= $jsUrl ?><!--global.js"></script>-->
    <script>

        //弹出隐藏层
        function ShowDiv(show_div,bg_div){
            document.getElementById(show_div).style.display='block';
            document.getElementById(bg_div).style.display='block' ;
            var bgdiv = document.getElementById(bg_div);
            bgdiv.style.width = document.body.scrollWidth;
            // bgdiv.style.height = $(document).height();
            $("#"+bg_div).height($(document).height());
        };
        //关闭弹出层
        function CloseDiv(show_div,bg_div){
            document.getElementById(show_div).style.display='none';
            document.getElementById(bg_div).style.display='none';
            //刷新页面跳转到兑换页面
            window.location.reload();
        };
        var c_count=<?=$count?>;
        var c_getcount=<?=$getcount?>;

        $(function($){

            var tmp="";
            if(c_getcount>=c_count){
                tmp='';

            }else {
                tmp=c_getcount+'/'+c_count;
            }

            $(".down_text").html(tmp);

                $("#btn_exec").click(
                    //获取卡片
                    function(){

                        var data={};
                        data.orderid=$("#hidden_orderid").val();
                        var re=returnjson("<?=Url::to(["wx-biz/get-card-handle"])?>",data);
                        if(re.flag==1){

                            ShowDiv('MyDiv','fade');
                        }else{
                            alert(re.msg);
                        };

                    }
                );

        });
    </script>
</head>
<body>

<input type="hidden" id="hidden_orderid" value="<?=$order_id?>"/>

<div class="main">
    <div class="top_bg">
        <div class="top_text_1">
            <img class="dlh" src="<?= $imgUrl ?>receive_gift_img/dlk.png" style="width:39px; height:46px;"/>
            <label class="text"><?=$card['VALID_DATE_MESSAGE']?></label>
            <label class="price_b" style="display: none;"><?=$card['PRICE']?></label><label class="price_a" style="display:none;">¥</label>
        </div>
        <div class="hr_div"></div>
        <div class="msg_div"><?=$card['NAME']?></div>
        <div class="but_div_a" id="btn_exec">
            <div class="but_div_text">立即领取</div>
        </div>
    </div>
    <div class="center">
        <div class="down_text"></div>
        <div class="down_text_spliter">
        </div>
    </div>
    <div class="down">
        <?php

        foreach ($rCards as &$rCard) {
           ?>
            <div class="list">
                <div class="list_1">
                    <img class="list_head" src="<?=$rCard['HEADER_URL']?>" style="width:40px; float: left;"/>
                    <div class="list_1_1">
                        <div class="list_name"><?=$rCard['NICK_NAME']?></div>
                        <div class="list_date"><?=$rCard['CREATE_DATETIME']?></div>
                    </div>
                    <label class="list_msg">领取了一张</label>
                </div>
                <div class="hr_b_div"></div>
            </div>

            <?php
        }

        ?>
       <!-- <div class="list">
            <div class="list_1">
                <img class="list_head" src="<?/*= $imgUrl */?>receive_gift_img/head.png" style="width:40px; float: left;"/>
                <div class="list_1_1">
                    <div class="list_name">谢勋</div>
                    <div class="list_date">12-14 20:11</div>
                </div>
                <label class="list_msg">领取了一张</label>
            </div>
            <div class="hr_b_div"></div>
        -->

    </div>
</div>
<!--弹出层时背景层DIV-->
<div id="fade" class="black_overlay"></div>
<div id="MyDiv" class="white_content">
    <div>
        <div style="width:274px; margin-right:auto; margin-left:">
            <img onclick="CloseDiv('MyDiv','fade')" src="<?=$imgUrl?>/receive_gift_img/delete.png" style="width:16px; height:16px; position:relative; margin-left:265px;"/>
        </div>
        <div>
            <img src="<?=$imgUrl?>/receive_gift_img/frame.png" style="width:258px; height:344px;"/>
        </div>
    </div>
</div>
</body>
</html>

